class Admin::UserLevelRulesController < ApplicationController

  layout "posts"

  before_filter :is_admin

  def index
    @rules = UserLevelRule.find(:all)
    if !(@rules.class == Array)
      @rules.to_ary
    end
  end

  def new
    @user_level_rule = UserLevelRule.new
    @user_levels = UserLevel.find(:all)
  end

  def create
    @user_level_rule = UserLevelRule.new(params[:user_level_rule])
		if @user_level_rule.save
      redirect_to rules_index_path
		else
			render :template => "admin/rules/new"
		end
  end

  def edit

  end

  def update

  end

  def destroy

  end

  private
  def is_admin
    return true if User.is_admin(session[:user_id])
    session[:denied_path] = request.request_uri
    redirect_to denied_path
  end

end